<?php
/**
 * 轻云网络验证系统
 * =======================================================
 * 版权所有(C) 2019-2039 daenx.cn，并保留所有权利。
 * 作者：Daen大恩
 * 作者QQ: 1330166565
 * 开发群：661059773
 * =======================================================
 */
    include 'farmwork.php';
	header("content-type:text/html;charset=utf-8");
	login();
	$sql = "SELECT * FROM duijie where lx='yzf'"; 
	$result=mysqli_query($con,$sql);
	if($result&&mysqli_num_rows($result)){
	   while ($row=mysqli_fetch_assoc($result)) {
			$yzf_kg = $row['kg'];
			$yzf_id = $row['shid'];
			$yzf_key = $row['shkey'];
	   }
	}

$li1233='class="active"';
$li12333='class="active"';
?>
<?php include 'header.php';?>
    <title>卡密充值-<?php echo $title?></title>
<?php include 'list.php';?>
    <!--main content start-->
    <section id="main-content">
        <section class="wrapper">
<?php include 'overview.php';?>
            <div class="row">
                <div class="col-lg-12">
                    <!--work progress start-->
                    <section class="panel panel-success">
                        <div class="panel-body progress-panel">
                            <div class="task-progress">
                                <h1>卡密充值</h1>
                                <p>使用卡密来充值代理余额</p>
					 <div class="panel-body">
					 
					<form action="./cz-km.php" method="get" class="form-inline" role="form">
            <div class="form-group">
              <label>卡密：</label>
              <input size="40" type="text" name="km" value="" class="form-control" placeholder="请输入您得到的卡密">
            </div>
								
            <input type="submit" name="submit" value="充值" class="btn btn-info"/> 
          </form> 

		

        </div>
<?php
//添加卡密
$time=time();
if($_GET[submit]=="充值"){
$km=$_GET[km];
if($km==""){
	echo("<script language=\"javascript\" type=\"text/javascript\" src=\"/data/assets/js/jquery.min.js\"></script><script language=\"javascript\" type=\"text/javascript\" src=\"/data/assets/layer/layer.js\"></script><script>layer.open({  type: 1  ,title: false   ,closeBtn: false  ,area: '200px;'  ,shade: 0.8  ,id: 'LAY_layuipro'   ,resize: false  ,btn: ['确定']  ,moveType: 1   ,content: '<div style=\"padding: 30px; line-height: 22px; background-color: #393D49; color: #fff; font-weight: 300;\">请输入卡密再充值哦！</div>'  ,success: function(layero){ var btn = layero.find('.layui-layer-btn');  btn.find('.layui-layer-btn0').attr({ href: 'cz-km.php' });  }});</script>");
}else{
	$sql="SELECT * FROM `daili_cami` where km='$km' limit 1";//判断卡密
	$row=mysqli_fetch_array(mysqli_query($con,$sql));
	if($row){
	$kmid=$row['id'];	
	$cp=$row['cp'];		
	$ye=$row['ye'];
	if($cp == $ycp){
		mysqli_query($con,"DELETE FROM `daili_cami` where `id` = $kmid ");//删除卡密
		$rmb = $rmb + $ye;
		$sql = "UPDATE `daili` SET `rmb` = '$rmb' where id='$uid'";
		mysqli_query($con,$sql);
		$ip = getip();
		$time1=time();
		$sql = "INSERT INTO `log_dl` (`uid`,`time`,`cp`,`rmb`,`zrmb`,`bz`,`ip`,`ddh`) VALUES ('$uid', '$time1', '$ycp', '+$ye', '$rmb', '卡密充值余额','$ip','');";//添加流水日志
		mysqli_query($con,$sql);
		echo("<script language=\"javascript\" type=\"text/javascript\" src=\"../data/assets/js/jquery.min.js\"></script><script language=\"javascript\" type=\"text/javascript\" src=\"../data/assets/layer/layer.js\"></script><script>layer.open({  type: 1  ,title: false   ,closeBtn: false  ,area: '200px;'  ,shade: 0.8  ,id: 'LAY_layuipro'   ,resize: false  ,btn: ['确定']  ,moveType: 1   ,content: '<div style=\"padding: 30px; line-height: 22px; background-color: #393D49; color: #fff; font-weight: 300;\"><p style=\"text-align:left;\"><label>账号：</label>".$dldomain."<br /><label>充值金额：</label>".$ye." &nbsp;&nbsp;<br /><label>总金额：</label>".$rmb." &nbsp;&nbsp;<br /></label><font style=\"color:#EE4000;\">——充值成功——</font></p></div>'  ,success: function(layero){ var btn = layero.find('.layui-layer-btn');  btn.find('.layui-layer-btn0').attr({ href: 'cz-km.php' });  }});</script>");

		
	}
		else{
			echo("<script language=\"javascript\" type=\"text/javascript\" src=\"/data/assets/js/jquery.min.js\"></script><script language=\"javascript\" type=\"text/javascript\" src=\"/data/assets/layer/layer.js\"></script><script>layer.open({  type: 1  ,title: false   ,closeBtn: false  ,area: '275px;'  ,shade: 0.8  ,id: 'LAY_layuipro'   ,resize: false  ,btn: ['确定']  ,moveType: 1   ,content: '<div style=\"padding: 30px; line-height: 22px; background-color: #393D49; color: #fff; font-weight: 300;\">您输入的卡密和您的所属代理不一致！</div>'  ,success: function(layero){ var btn = layero.find('.layui-layer-btn');  btn.find('.layui-layer-btn0').attr({ href: 'cz-km.php' });  }});</script>");
		}
	}else

	echo("<script language=\"javascript\" type=\"text/javascript\" src=\"/data/assets/js/jquery.min.js\"></script><script language=\"javascript\" type=\"text/javascript\" src=\"/data/assets/layer/layer.js\"></script><script>layer.open({  type: 1  ,title: false   ,closeBtn: false  ,area: '275px;'  ,shade: 0.8  ,id: 'LAY_layuipro'   ,resize: false  ,btn: ['确定']  ,moveType: 1   ,content: '<div style=\"padding: 30px; line-height: 22px; background-color: #393D49; color: #fff; font-weight: 300;\">卡密不存在或者已被使用！</div>'  ,success: function(layero){ var btn = layero.find('.layui-layer-btn');  btn.find('.layui-layer-btn0').attr({ href: 'cz-km.php' });  }});</script>");
	
}
mysqli_close();
}
?>
                            </div>
                        </div>						


                    </section>
                    <!--work progress end-->
                </div></div>

        </section>
    </section>
    <!--main content end-->

<?php include 'footer.php';?>
